package demo8;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import com.alibaba.druid.pool.DruidDataSource;

/**
 * Spring 配置类
 * <p>
 * 被@Configuration 标记的类，会被 Spring 容器识别为配置类，
 */
@Configuration
@ComponentScan("demo8")//指明容器要扫描哪个包
public class Config {

    @Bean
    public Student initstudent() {
        return new Student();
    }

    @Bean
    public DruidDataSource initDataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true");
        dataSource.setUsername("root");
        dataSource.setPassword("root");
        dataSource.setMaxActive(10);
        dataSource.setInitialSize(5);
        return dataSource;
    }
}
